//
//  SelectableCategoryColorSystem.cpp
//  QuizMaster
//
//  Created by Jeppe Nielsen on 4/9/15.
//  Copyright (c) 2015 Jeppe Nielsen. All rights reserved.
//

#include "SelectableCategoryColorSystem.hpp"


void SelectableCategoryColorSystem::Initialize() {
    AddComponent<Transform>();
    AddComponent<SelectableCategory>();
    AddComponent<Colorable>();
}

void SelectableCategoryColorSystem::Update(float dt) {

   for (ObjectCollection::const_iterator it = Objects().begin(); it!=Objects().end(); ++it) {
        GameObject* object = *it;
        Transform* transform = object->GetComponent<Transform>();
        Colorable* color = object->GetComponent<Colorable>();
        Vector3 worldPosition = transform->World.GetValue()->TransformPosition(transform->Anchor);
        color->Color = worldPosition.x>0 ? Colour::Green() : Colour::Red();
    }
}

